package io.web.usercenter.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.web.usercenter.common.validation.group.Add;
import io.web.usercenter.common.validation.group.Edit;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.ibatis.annotations.Param;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

/**
 * 用户
 * @TableName user
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class UserVo extends PageVo implements Serializable {
    /**
     * id
     */
    private Long id;

    /**
     * 用户昵称
     */
    @NotBlank(groups = {Add.class, Edit.class})
    @Length(min = 4, max = 20, groups = {Add.class, Edit.class})
    // 取反 [`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]
    // ^((?!要取反的正则表达式).)*$
    @Pattern(regexp = "^((?![`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]).)*$",
            groups = {Add.class, Edit.class}, message = "不能包含特殊字符")
    private String username;

    /**
     * 账号
     */
    @NotBlank(groups = {Add.class, Edit.class})
    @Length(min = 4, max = 20, groups = {Add.class, Edit.class})
    @Pattern(regexp = "^((?![`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]).)*$",
            groups = {Add.class, Edit.class}, message = "不能包含特殊字符")
    private String userAccount;

    /**
     * 用户头像
     */
    private String avatarUrl;

    /**
     * 性别
     */
    @NotNull(groups = {Add.class, Edit.class})
    private Integer gender;

    /**
     * 密码
     */
    @NotBlank(groups = {Edit.class})
    @Length(min = 8, max = 20, groups = {Edit.class})
    private String userPassword;

    /**
     * 电话
     */
    @NotBlank(groups = {Add.class, Edit.class})
    @Pattern(regexp = "((\\d{11})|^((\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1})|(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1}))$)",
            message = "无效的电话号码",
            groups = {Add.class, Edit.class})
    private String phone;

    /**
     * 邮箱
     */
    @NotBlank(groups = {Add.class, Edit.class})
    @Email(groups = {Add.class, Edit.class}, message = "无效的邮箱")
    private String email;

    /**
     * 状态 0 - 正常
     */
    private Integer userStatus;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /**
     *
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    /**
     * 是否删除
     */
    private Integer isDelete;

    /**
     * 用户角色 0 - 普通用户 1 - 管理员
     */
    private Integer userRole;


    private String planetCode;

    private static final long serialVersionUID = 1L;
}